#!/bin/bash
#监控从MySQL IO/SQL线程状态

user=root
password=WWW.1.com

state_IO=$(mysql -u${user} -p${password} -e "show slave status\G" 2> /dev/null | grep -w "Slave_IO_Running" | awk '{print $2}')
state_SQL=$(mysql -u${user} -p${password} -e "show slave status\G" 2> /dev/null | grep -w "Slave_SQL_Running" | awk '{print $2}')
if [ "${state_IO}" = "Yes" ];then
   echo "IO进程正常运行"
else
   echo "IO进程异常"
fi

if [ "${state_SQL}" = "Yes" ];then
   echo "SQL进程正常运行"
else
   echo "SQL进程异常"
fi

